home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Mac / Tools / twit / twit.py < prev    next >
Encoding:
Python Source  |  2000-06-23  |  1.3 KB  |  60 lines

  1. """twit - The Window-Independent Tracer.
  2.  
  3. Interface:
  4. twit.main()                        Enter debugger in inactive interactive state
  5. twit.run(stmt, globals, locals)    Enter debugger and start running stmt
  6. twit.post_mortem(traceback)        Enter debugger in post-mortem mode on traceback
  7. twit.pm()                        Enter debugger in pm-mode on sys.last_traceback
  8.  
  9. main program: nothing but a bit of glue to put it all together.
  10.  
  11. Jack Jansen, CWI, August 1996."""
  12.  
  13. import os
  14. import sys
  15.  
  16. # Add our directory to path, if needed
  17. dirname = os.path.split(__file__)[0]
  18. if not dirname in sys.path:
  19.     sys.path.append(dirname)
  20.  
  21. if os.name == 'mac':
  22.     import MacOS
  23.     MacOS.splash(502)    # Try to show the splash screen
  24.     import mactwit_app; twit_app = mactwit_app
  25. else:
  26.     try:
  27.         import _tkinter
  28.         have_tk = 1
  29.     except ImportError:
  30.         have_tk = 0
  31.     if have_tk:
  32.         import tktwit_app; twit_app = tktwit_app
  33.     else:
  34.         print 'Please implementent machine-dependent code and try again:-)'
  35.         sys.exit(1)
  36.     
  37. import sys
  38.     
  39. def main():
  40.     twit_app.Initialize()
  41.     if os.name == 'mac':
  42.         MacOS.splash()
  43.     twit_app.Twit('none', None)
  44.     
  45. def run(statement, globals=None, locals=None):
  46.     twit_app.Initialize()
  47.     twit_app.Twit('run', (statement, globals, locals))
  48.  
  49. def post_mortem(t):
  50.     Initialize()
  51.     twit_app.Twit('pm', t)
  52.     
  53. def pm():
  54.     post_mortem(sys.last_traceback)
  55.     
  56. if __name__ == '__main__':
  57.     main()
  58.     
  59.     
  60.